package com.starview.star.operators.ast.runtime;

import com.starview.platform.data.EvaluationException;
import com.starview.platform.data.IFunction;
import com.starview.platform.data.IValue;
import com.starview.platform.data.type.IType;
import com.starview.platform.data.type.Location;
import com.starview.platform.data.type.TypeUtils;
import com.starview.star.operators.CafeEnter;

public class MergeLocation implements IFunction
{
  public static final String name = "__mergeLocation";

  @CafeEnter
  public static Location enter(Location loc1, Location loc2) throws EvaluationException
  {
    return loc1.extendWith(loc2);
  }

  @Override
  public IValue enter(IValue... args) throws EvaluationException
  {
    return enter((Location) args[0], (Location) args[1]);
  }

  @Override
  public IType getType()
  {
    return type();
  }

  public static IType type()
  {
    return TypeUtils.functionType(Location.type, Location.type, Location.type);
  }
}
